import {JSEncrypt} from 'jsencrypt'
// 密钥对生成 http://web.chacuo.net/netrsakeypair
const publicKey ='MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBANWNPt7m5Cb7Dn8LQ9I+kauxXWUqOsUb'+
    'wSO6b2oNAohjvaSk5wVoln+nX4d70WJM0kigmnC8oNou0fnjmX1yFAsCAwEAAQ=='
const privateKey ='MIIBVQIBADANBgkqhkiG9w0BAQEFAASCAT8wggE7AgEAAkEA1Y0+3ubkJvsOfwtD'+
'0j6Rq7FdZSo6xRvBI7pvag0CiGO9pKTnBWiWf6dfh3vRYkzSSKCacLyg2i7R+eOZ'+
'fXIUCwIDAQABAkEAg9XWCXALS9FT6rR+oy4DajZuDQVcENGIk9EF9Teg56ditIYt'+
'K7Qq0r2owbEGgkncVCQXPew+EHFkn9faThibYQIhAPRRX6D1M5pxD2F+BXN4J0uT'+
'PGaOsOeK1I/QavWotbtRAiEA38NFxOcqVQ8G+l1nJ49yiHLWVXGCkkWePvCanF1w'+
'ipsCIEzjgxXztQ7IwA9tiqehS7SUHLEl/PSRk33DGLZBJxhRAiBiy80aSxadx6zF'+
'DkhlZyiiplGMGDoWazabg5BASeFO0QIhAJu1QFSdF+aKkZ5B2/R1B8TlRDG9aQzH'+
'xBBLFTAcfq3+'
/*const publicKey =
    'MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKoR8mX0rGKLqzcWmOzbfj64K8ZIgOdH\n' +
    'nzkXSOVOZbFu/TJhZ7rFAN+eaGkl3C4buccQd/EjEsj9ir7ijT7h96MCAwEAAQ=='
const privateKey =
    'MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEAqhHyZfSsYourNxaY\n' +
    '7Nt+PrgrxkiA50efORdI5U5lsW79MmFnusUA355oaSXcLhu5xxB38SMSyP2KvuKN\n' +
    'PuH3owIDAQABAkAfoiLyL+Z4lf4Myxk6xUDgLaWGximj20CUf+5BKKnlrK+Ed8gA\n' +
    'kM0HqoTt2UZwA5E2MzS4EI2gjfQhz5X28uqxAiEA3wNFxfrCZlSZHb0gn2zDpWow\n' +
    'cSxQAgiCstxGUoOqlW8CIQDDOerGKH5OmCJ4Z21v+F25WaHYPxCFMvwxpcw99Ecv\n' +
    'DQIgIdhDTIqD2jfYjPTY8Jj3EDGPbH2HHuffvflECt3Ek60CIQCFRlCkHpi7hthh\n' +
    'YhovyloRYsM+IS9h/0BzlEAuO0ktMQIgSPT3aFAgJYwKpqRYKlLDVcflZFCKY7u3\n' +
    'UP8iWi1Qw0Y='*/
// 加密
export function encrypt(txt) {
    const encryptor = new JSEncrypt()
    encryptor.setPublicKey(publicKey) // 设置公钥
    return encryptor.encrypt(txt) // 对数据进行加密
}
// 解密
export function decrypt(txt) {
    const encryptor = new JSEncrypt()
    encryptor.setPrivateKey(privateKey) // 设置私钥
    return encryptor.decrypt(txt) // 对数据进行解密
}